package com.mapforge.util;

import java.awt.LayoutManager;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public final class SwingUtil {
	private SwingUtil() {
	}

	public static final void initializeFrame(JFrame frame) {
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.pack();
		frame.setLocationRelativeTo(null);
	}

	public static final JPanel wrapFieldInPanel(String text, JComponent jcomp,
			LayoutManager layout) {
		JPanel panel = new JPanel(layout);
		panel.add(new JLabel(text));
		panel.add(jcomp);
		return panel;
	}

	public static final JButton createButton(String s, ActionListener listener) {
		JButton b = new JButton(s);
		b.addActionListener(listener);
		return b;
	}
}
